import { JhaoProto } from "../../src/lib/net/protobuf/jhaoproto";

export class ClubModel {

    public clubid: number;
    public creator: number;
    public message: string;
    public state: number;
    public seemember: number;
    public seerank: number;
    public limit_join: number;

    public actor: number;
    public name: string;
    public tablecount: number;
    public usercount: number;
    public headimg: string
    public lv: number
    public nick_name: string
    public online: number
    public user_state: number;
    public quanxian: string

    // public static data2Mdoel(data: object) {
    //     let model: ClubModel = new ClubModel();
    //     model.clubid = data["clubid"]
    //     model.actor = data["actor"]
    //     model.creator = data["creator"]
    //     model.message = data["message"]
    //     model.name = data["name"]
    //     model.state = data["state"]
    //     model.tablecount = data["tablecount"]
    //     model.usercount = data["usercount"]
    //     model.headimg = data["headimg"]
    //     model.lv = data["lv"]
    //     model.nick_name = data["nick_name"]
    //     model.online = data["online"]
    //     model.seemember = data["seemember"]
    //     model.seerank = data["seerank"]
    //     model.limit_join = data["limit_join"]
    //     model.user_state = data["user_state"]
    //     model.quanxian = data["quanxian"]
    //     return model
    // }

    // public static data2ModelList(clubs: Array<object>) {
    //     let clubList: Array<ClubModel> = []
    //     for (let i = 0; i < clubs.length; i++) {
    //         let model: ClubModel = this.data2Mdoel(clubs[i])
    //         clubList[i] = model;
    //     }
    //     return clubList
    // }

    public static data2IClubInfo(data: object) {
        let club: JhaoProto.IClubInfo = {
            clubid: data["clubid"],
            creator: data["creator"],
            clubName: data["club_name"],
            notice: data["notice"],
            createTime: new Date(data["create_time"]).getTime(),
            clubState: data["club_state"],
            actor: data["actor"],
            joinTime: new Date(data["join_time"]).getTime(),
            approver: data["approver"],
            usercount: data["usercount"],
            headimg: data["headimg"],
            nickName: data["nick_name"],
            sex: data["sex"],
            userState:data["user_state"]
        }
        return club
    }


    public static data2IClubInfoList(clubs: Array<object>) {
        let resultClubs: Array<JhaoProto.IClubInfo> = []
        for (let i = 0; i < clubs.length; i++) {
            resultClubs[i] = this.data2IClubInfo(clubs[i])
        }
        return resultClubs
    }


}